//商品相关接口
import request from "@/utils/request.ts";
import type { SpuResponseData } from "./type";

// 品牌接口

enum API {
  // 商品SPU接口 : Spu Manage ControllerShow/HideList OperationsExpand Operations
  // GET
  baseSaleAttrList = "/admin/product/baseSaleAttrList",
  // getBaseSaleAttrList

  // DELETE
  deleteSpu = "/admin/product/deleteSpu",
  // 删除Spu

  // GET
  findSpuInfoByKeyword = "/admin/product/findSpuInfoByKeyword",
  // findSpuInfoByKeyword

  // GET
  getSpuById = "/admin/product/getSpuById",
  // 获取spu基本信息

  // POST
  findSpuInfoBySpuIdList = "/admin/product/inner/findSpuInfoBySpuIdList",
  // findSpuInfoBySpuIdList

  // POST
  saveSpuInfo = "/admin/product/saveSpuInfo",
  // saveSpuInfo

  // POST
  updateSpuInfo = "/admin/product/updateSpuInfo",
  // 更改spu信息

  // GET
  getPageList = "/admin/product",
  // 获取分页信息
}

export const baseSaleAttrList = () =>
  request.get<any, any>(API.baseSaleAttrList);

export const deleteSpu = (spuId: number) =>
  request.delete<any, any>(API.deleteSpu + `/${spuId}`);

export const findSpuInfoByKeyword = (keyword: string) =>
  request.get<any, any>(API.findSpuInfoByKeyword + `/${keyword}`);

export const getSpuById = (spuId: number) =>
  request.get<any, any>(API.getSpuById + `/${spuId}`);

export const findSpuInfoBySpuIdList = (data: any) =>
  request.post<any, any>(API.findSpuInfoBySpuIdList, data);

export const saveSpuInfo = (data: any) =>
  request.post<any, any>(API.saveSpuInfo, data);

export const updateSpuInfo = (data: any) =>
  request.post<any, any>(API.updateSpuInfo, data);

export const getPageList = (page: number, limit: number, category3Id: number) =>
  request.get<any, SpuResponseData>(
    API.getPageList + `/${page}/${limit}?category3Id=${category3Id}`,
  );
